#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
bool st;
int t;
const int N=1e5+5,M=1e6+5;
int n,m,L,V;
int d[N],v[N],a[N];
int p[N];
pii all[N];
int num[M];
bool ed;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        int mx=0;
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            mx=max(mx,d[i]);
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        p[m+1]=1e9;
        int x=1;
        for(int i=1;i<=mx;i++){
            num[i]=x;
            if(i==p[x]){
                x++;
            }
        }
        int cnt=0;
        for(int i=1;i<=n;i++){
            int id=num[d[i]];
            if(id>m){
                continue;
            }
            if(a[i]==0){
                if(v[i]>V){
                    all[++cnt]=mp(id,m);
                }
            }else if(a[i]<0){
                if(v[i]>V){
                    int l=id,r=m;
                    int cur=v[i]*v[i]-V*V;
                    int now=-a[i];
                    if(cur<=2*now*(p[id]-d[i])){
                        continue;
                    }
                    while(l<r){
                        int mid=(l+r+1)>>1;
                        int tmp=p[mid]-d[i];
                        if(2*now*tmp<cur){
                            l=mid;
                        }else{
                            r=mid-1;
                        }
                    }
                    all[++cnt]=mp(id,l);
                }
            }else{
                if(v[i]>V){
                    all[++cnt]=mp(id,m);
                }else{
                    int cur=V*V-v[i]*v[i];
                    int l=id,r=m;
                    if(2*a[i]*(p[m]-d[i])<=cur){
                        continue;
                    }
                    while(l<r){
                        int mid=(l+r)>>1;
                        int tmp=p[mid]-d[i];
                        if(2*a[i]*tmp<=cur){
                            l=mid+1;
                        }else{
                            r=mid;
                        }
                    }
                    all[++cnt]=mp(l,m);
                }
            }
        }
        printf("%d ",cnt);
        sort(all+1,all+1+cnt);
        int ans=m;
        int mn=1e9;
        for(int i=1;i<=cnt;i++){
            bool fl=0;
            if(mn==1e9){
                ans--;
                mn=all[i].se;
                continue;
            }
            if(mn<all[i].fi){
                mn=1e9;
                ans--;
            }
            mn=min(mn,all[i].se);
        }
        printf("%d\n",ans);
    }
    return 0;
}